// Created by WXX on 2022/2/2 9:51
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

/**
 * 执行用时：0 ms, 在所有 C++ 提交中击败了100.00%的用户
 * 内存消耗：6 MB, 在所有 C++ 提交中击败了83.29%的用户
 */
class Solution {
public:
    string reversePrefix(string word, char ch) {

        int j = -1;
        for (int i = 0; i < word.size(); i++)
            if (word[i] == ch) {
                j = i;
                break;
            }

        if (j == -1) return word;
        int i = 0;
        while (i < j) swap(word[i++], word[j--]);
        return word;
    }
};

int main() {

    cout << Solution().reversePrefix("abcdef", 'd') << endl;

    return 0;
}
